/**
 * 测试SetFile
 */
package com.tjh.hadoop.file;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.SetFile;
import org.junit.Test;

/**
 * @author jahen
 * @date 2016年9月11日
 * @time 上午11:56:49
 * @category Hadoop SetFile
 */
public class TestSetFile {
	/**
	 * SetFile写入的仅是Writable的键，值为null
	92      (null)
	93      (null)
	94      (null)
	95      (null)
	96      (null)
	97      (null)
	98      (null)
	99      (null)
	 */
	@Test
	public void write() throws Exception {
		Configuration conf = new Configuration();
		conf.set("fs.defaultFs", "file:///");
		FileSystem fs = FileSystem.get(conf);
		@SuppressWarnings("deprecation")
		SetFile.Writer writer = new SetFile.Writer(fs, "file:///f:/test/set.set",IntWritable.class);
		
		IntWritable key = new IntWritable();
		for(int i=0; i<100; i++) {
			key.set(i);
			writer.append(key);
		}
		writer.close();
		fs.close();
	}
}
